<?php 
	include("header.php");
	include("top_menu.php");
?>

<title> Registered Users </title>
<div class = "showusers">
	<?php
		$connection = mysql_pconnect("localhost" , "root" , "31122001");
    	mysql_select_db("kt_site");
    	$query = "SELECT * FROM users;";
		$sql = mysql_query($query);
		echo "<form name='deleteform' action = 'deleteuser.php' method = 'POST'>";
		
		echo "<div class = 'div-header-su'>";
		echo "<div id = 'div-header-su-c1'> Username </div>";
		echo "<div id = 'div-header-su-c2'> Last Name </div>";
		echo "<div id = 'div-header-su-c3'> First Name </div>";
		echo "<div id = 'div-header-su-c4'> Phone Number </div>";
		echo "</div>";		
		
		for ($i = 0 ; $i < mysql_num_rows($sql) ; $i++) {
			$user = mysql_fetch_array($sql);
			if ($user['username'] != 'Admin') {
				echo "<div class = 'div-row-su'>";
				echo "<div id = 'div-row-su-c1'> <input type = 'checkbox' name = 'userstodelete[]' value = '".$user['username']."'></div>";				
				echo "<div id = 'div-row-su-c2'>".$user['username']."</div>";
				echo "<div id = 'div-row-su-c3'>".$user['lastname']."</div>";		
				echo "<div id = 'div-row-su-c4'>".$user['firstname']."</div>";		
				echo "<div id = 'div-row-su-c5'>".$user['phonenumber']."</div>";		
				echo "</div>";
			}
		}	
		if (strcmp($_SESSION['username'], 'Admin') == 0) {
			echo "<input type = 'submit' name = 'Delete' value = 'Delete choosen' class = 'button delete-button'>";
		}
		echo "</form>";
	?>
</div>